<template>
  <div class="certification">
    <my-tabs :tab-list="tabList"></my-tabs>
    <template v-if="$util.isDef(status)">
      <auth-state
        v-if="status == 0 || status == 1 || status == 2 || status == 3"
        :data="init"
        @again="handleAgain"
      ></auth-state>
      <auth-form :data="init" :status="status" v-else-if="status == 4 || status == 5"></auth-form>
    </template>
  </div>
</template>

<script>
/**
 * status 认证状态
 * 0：禁用 认证通过之后禁用
 * 1：正常 认证通过
 * 2：待审 审核中
 * 3：驳回 认证失败
 * 4：未认证
 * 5：未认证 自定义驳回跳转
 */
import MyTabs from '../components/myTab.vue'
import AuthForm from './components/authForm.vue'
import AuthState from './components/authState.vue'
export default {
  components: {
    MyTabs,
    AuthForm,
    AuthState
  },
  data() {
    return {
      tabList: [
        {
          title: '认证中心'
        }
      ],
      status: null,
      init: ''
    }
  },
  mounted() {
    this.handleAuthInit()
  },
  methods: {
    handleAuthInit() {
      this.$api.getTeacherAuth(res => {
        this.status = res.data.auth_status
        this.init = res.data
      })
    },
    handleAgain(val) {
      this.status = val
    }
  }
}
</script>

<style lang="scss" scoped></style>
